Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
@types/yargs
Advanced tools
The @types/yargs package provides TypeScript type definitions for the yargs library, which is a tool to help build interactive command line tools, by parsing arguments and generating an elegant user interface. It helps TypeScript developers to have auto-completion and type checking when using yargs.
Command Module Definition
Defines a command with options. This example creates a 'get' command with a required 'url' option.
import * as yargs from 'yargs';
yargs.command('get', 'make a get HTTP request', {
url: {
describe: 'URL to make request to',
demand: true,
alias: 'u',
type: 'string'
}
}, (argv) => {
console.log(`Making a GET request to: ${argv.url}`);
});
Option Parsing
Parses command line options. This example parses a boolean 'verbose' option.
import * as yargs from 'yargs';
const argv = yargs.option('verbose', {
alias: 'v',
type: 'boolean',
description: 'Run with verbose logging'
}).argv;
if (argv.verbose) console.log('Verbose mode on');
Help and Version Setup
Sets up automatic version and help message support. This example sets the version of the CLI tool and enables the default help support.
import * as yargs from 'yargs';
yargs.version('1.0.0').help().argv;
Commander is another popular npm package for building command line interfaces. It offers a high-level API for creating commands and options, similar to yargs. Commander is known for its simplicity and ease of use, but yargs provides more detailed control over argument parsing and generates more comprehensive help messages automatically.
Meow is a lighter alternative to yargs for building CLI tools. It focuses on simplicity and minimal configuration. While it is easier to set up for simple scripts, yargs offers more advanced features like command-specific options, middleware, and automatic help generation.
npm install --save @types/yargs
This package contains type definitions for yargs (https://github.com/chevex/yargs).
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/yargs/v12.
These definitions were written by Martin Poelstra, Mizunashi Mana, Jeffery Grajkowski, Jimi (Dimitris) Charalampidis, Steffen Viken Valvåg, Emily Marigold Klassen, and ExE Boss.
FAQs
TypeScript definitions for yargs
The npm package @types/yargs receives a total of 55,385,819 weekly downloads. As such, @types/yargs popularity was classified as popular.
We found that @types/yargs demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.